﻿<%@ Page Title="Категории" Language="C#" MasterPageFile="~/LeftColumn.master" AutoEventWireup="true" CodeBehind="Categories.aspx.cs" Inherits="Supermarket.Web.CashierPages.Categories" %>
<asp:Content ID="Content1" ContentPlaceHolderID="RightContent" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="upCategories" runat="server">
        <ContentTemplate>
            <asp:GridView ID="GridViewCategories" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
                CellPadding="3" CellSpacing="2" DataSourceID="odsCategories" PageSize="15" DataKeyNames="CategoryId">
                <Columns>
                    <asp:CommandField CancelText="Отказ" DeleteText="Изтрий" EditText="Редактирай" InsertText="Добави"
                        NewText="Нов" ShowDeleteButton="True" ShowEditButton="True" UpdateText="Обнови" />
                    <asp:BoundField DataField="CategoryName" HeaderText="Категории" SortExpression="CategoryName">
                        <ControlStyle Width="500px" />
                    </asp:BoundField>
                </Columns>
                <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
                <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
                <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
                <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
                <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
                <SortedAscendingCellStyle BackColor="#FFF1D4" />
                <SortedAscendingHeaderStyle BackColor="#B95C30" />
                <SortedDescendingCellStyle BackColor="#F1E5CE" />
                <SortedDescendingHeaderStyle BackColor="#93451F" />
            </asp:GridView>            
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:UpdatePanel ID="upAdd" runat="server">
        <ContentTemplate>
            <asp:FormView ID="fvCategory" runat="server" DefaultMode="Insert" 
                DataSourceID="odsCategories">
                <InsertItemTemplate>
                    <p>
                        <strong>Категория:</strong>
                        <asp:TextBox ID="txtTitle" runat="server" Text='<%# Bind("CategoryName") %>' /></p>
                    <p>
                        <asp:LinkButton ID="lbAdd" runat="server" Text="Добави" CommandName="Insert" />
                    </p>
                </InsertItemTemplate>
            </asp:FormView>
            <asp:Label ID="LabelError" runat="server" CssClass="failureNotification"></asp:Label>            
        </ContentTemplate>
    </asp:UpdatePanel>   

    <asp:ObjectDataSource ID="odsCategories" runat="server" 
        DeleteMethod="Delete" 
        InsertMethod="CreateCategory" 
        SelectMethod="GetAllCategories" TypeName="Supermarket.Bll.CategoryManager" 
        UpdateMethod="Update" oninserted="odsCategories_Inserted">
        <DeleteParameters>
            <asp:Parameter Name="categoryId" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="categoryName" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="categoryId" Type="Int32" />
            <asp:Parameter Name="categoryName" Type="String" />
        </UpdateParameters>        
    </asp:ObjectDataSource>
</asp:Content>
